package com.ryhx.pay.base.app.userinfo.dao.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Component;

import com.ryhx.pay.base.app.modelUserInfo;
import com.ryhx.pay.base.app.userinfo.dao.UserInfoDao;
import com.ryhx.pay.common.exceptions.BizException;

@Component("userInfoDao")
public class UserInfoDaoImpl implements UserInfoDao {

	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public UserInfo getUserInfo(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectOne("UserInfoMapper.getUserInfo", query);
	}

	@Override
	public List<UserInfo> getUserInfoList(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectList("UserInfoMapper.getUserInfoList", query);
	}

	@Override
	public Integer getUserInfoListCount(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectOne("UserInfoMapper.getUserInfoListCount", query);
	}

	@Override
	public int batchInsertUserInfo(List<UserInfo> list) throws BizException {
		return sqlSessionTemplate.insert("UserInfoMapper.batchInsertUserInfo", list);
	}

	@Override
	public int batchReplaceUserInfo(List<UserInfo> list) throws BizException {
		return sqlSessionTemplate.insert("UserInfoMapper.batchReplaceUserInfo", list);
	}

	@Override
	public int batchUpdateUserInfo(List<UserInfo> list) throws BizException {
		return sqlSessionTemplate.update("UserInfoMapper.batchUpdateUserInfo", list);
	}

	@Override
	public Long insertUserInfo(UserInfo userInfo) throws BizException {
		sqlSessionTemplate.insert("UserInfoMapper.insertUserInfo", userInfo);
		return userInfo.getEntityId();
	}

	@Override
	public Long replaceUserInfo(UserInfo userInfo) throws BizException {
		sqlSessionTemplate.insert("UserInfoMapper.replaceUserInfo", userInfo);
		return userInfo.getEntityId();
	}

	@Override
	public int updateUserInfo(UserInfo userInfo) throws BizException {
		return sqlSessionTemplate.update("UserInfoMapper.updateUserInfo", userInfo);
	}

	@Override
	public int updateUserInfoWithoutNull(UserInfo userInfo) throws BizException {
		return sqlSessionTemplate.update("UserInfoMapper.updateUserInfoWithoutNull", userInfo);
	}

	@Override
	public int updateUserInfoByWhereSql(Map<String, Object> userInfo) throws BizException {
		return sqlSessionTemplate.update("UserInfoMapper.updateUserInfoByWhereSql", userInfo);
	}

	@Override
	public int truncateUserInfo() throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.truncateUserInfo");
	}

	@Override
	public int deleteUserInfo(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.deleteUserInfo", query);
	}

	@Override
	public int deleteUserInfoList(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.deleteUserInfoList", query);
	}

	@Override
	public int deleteUserInfoByWhereSql(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.deleteUserInfoByWhereSql", query);
	}

	@Override
	public int batchDeleteUserInfo(List<Long> list) throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.batchDeleteUserInfo", list);
	}

	@Override
	public int batchDeleteUserInfoList(List<UserInfo> list) throws BizException {
		return sqlSessionTemplate.delete("UserInfoMapper.batchDeleteUserInfoList", list);
	}
}
